var shipNews = new Array('1','0','0');
$(document).ready(function(){
	//异步加载法律法规，扶持政策，人才市场信息
	initPageInfo();

//	$('#tagContent li').mouseover(function(e){
//		
//	});
	var hyid = $('#hyid').val();
	var hytoken = $('#hytoken').val();
	var cbjytarget = $("#cbjytarget").attr("href")+'?hyid='+hyid+'&hytoken='+hytoken;
	$("#cbjytarget").attr("href",cbjytarget);
});
function selectTag(showContent,selfObj){
	// 操作标签
	var tag = document.getElementById("tags").getElementsByTagName("li");
	var taglength = tag.length;
	for(i=0; i<taglength; i++){
		tag[i].className = "";
	}
	selfObj.parentNode.className = "selectTag";
	// 操作内容
	for(i=9; j=document.getElementById("tagContent"+i); i++){
		j.style.display = "none";
	}
	var locThemeId = showContent.substr(10);
	if(shipNews[locThemeId - 11] != '1') {
		var url= mainDomain + '/front/findArticleList.action';
		$.post(url,{'locChannelId':1,'locThemeId':locThemeId,'rows':7},function(data){
			if(data.success == false){
				console.log(data.message);
			}else{
				if(data.data.infoList.length > 0) {
					var infoDiv = '<div><h2 id="hid' + locThemeId + '" style="color:rgba(0, 119, 255, 1);margin-top:5px;text-align:center;">';
						infoDiv += data.data.infoList[0].title;
						infoDiv += '</h2><div style="width:365px;margin-left:15px;"><p id="pid'+ locThemeId + '" style="text-indent:2em;word-wrap:break-word; word-break:break-all;padding-bottom:10px;border-bottom:1.5px dotted;height:45px;">';
						infoDiv += data.data.infoList[0].infoNote;
						infoDiv += '</p></div></div><ul>';
						$.each(data.data.infoList,function(i,v){
							infoDiv += '<li><span>'+dateToStr(v.createTime)+'</span><a href="'+mainDomain+'/front/infoDetailPage/'+v.id+'" target="_blank" onMouseOver="changetitle('+locThemeId+ ','+ v.id+ ')">·'+v.title+'</a></li>';
						});
						infoDiv += '</ul>';
						infoDiv += '<ul style="text-align:right"><a href="/front/findArticleListBySection/1/';
						infoDiv += locThemeId;
						infoDiv += '"><span  style="font-size:13px; color:#0066ff; font-family:SimSun; ">更多>></span></a></ul>';
						$("#"+showContent).html(infoDiv);
					shipNews[locThemeId-11] = "1";
				}
			}
		});
	}
	
	document.getElementById(showContent).style.display = "block";
	
	
}


function initPageInfo() {
	//异步加载法律法规，扶持政策，人才市场信息
	var url= mainDomain + '/front/findArticleList.action';
	//法律法规
	$.post(url,{'locChannelId':6,'locThemeId':28,'rows':5},function(data){
		if(data.success == true){
			if(data.data.infoList.length > 0) {
				var infoDiv = '<ul>';
				$.each(data.data.infoList,function(i,v){
					infoDiv += '<li><a href="'+mainDomain+'/front/infoDetailPage/'+v.id+'" target="_blank">·'+v.title+'</a></li>'
				});
				infoDiv += '</ul>'
					$("#lawInfo").html(infoDiv);
			}
		}
	});
	//扶持政策
	$.post(url,{'locChannelId':6,'locThemeId':31,'rows':5},function(data){
		if(data.success == true){
			if(data.data.infoList.length > 0) {
				var infoDiv = '<ul>';
				$.each(data.data.infoList,function(i,v){
					infoDiv += '<li><a href="'+mainDomain+'/front/infoDetailPage/'+v.id+'" target="_blank">·'+v.title+'</a></li>'
				});
				infoDiv += '</ul>'
					$("#supportInfo").html(infoDiv);
			}
		}
	});
	//滚动新闻
	$.post(url,{'locChannelId':1, 'fileUrl': '1', 'rows':4},function(data){
		if(data.success == true){
			var $list = data.data.infoList;
			if($list.length > 0) {
				var ul = cols = "";
				$.each($list, function(i, entry){
					var href = mainDomain + "/front/infoDetailPage/" + entry.id;
					var picurl = entry.coverPicUrl;
					if(picurl.split(",").length>1)
					{
						picurl = picurl.substring(0,picurl.indexOf(","));
					}
					ul += "<li><a href=\""+href+"\" target=\"_blank\"><img src=\""+picurl+"\" alt=\""+entry.title+"\" width=\"590\" height=\"350\"/></a></li>";
					cols += "<li class=\"number-cols-li\" title=\""+entry.title+"\">" + (i+1) + "</li>";
				});
				$(".rolling-ul").html(ul);
				$(".number-cols").html(cols);
				$(".number-cols").find("li").first().addClass("selected-li");
				$(".number").find("h2").text($(".selected-li").attr("title"));
			}
		}
	});
	//注册会员
	$.post(url,{'locChannelId':50,'locThemeId':51},function(data){
		if(data.success == true){
			if(data.data.infoList.length > 0) {
				var infoDiv = '<ul>';
				$.each(data.data.infoList,function(i,v){
					infoDiv += '<li><span>·'+v.title+'</span></li>'
				});
				infoDiv += '</ul>'
					$("#zchyInfo").html(infoDiv);
			}
		}
	});
	//支撑单位
	$.post(url,{'locChannelId':50,'locThemeId':53},function(data){
		if(data.success == true){
			if(data.data.infoList.length > 0) {
				var infoDiv = '<ul>';
				$.each(data.data.infoList,function(i,v){
					infoDiv += '<li><a target="_blank" href="'+v.coverPicUrl+'">·  '+v.title+'</a></li>'
				});
				infoDiv += '</ul>'
					$("#p_gda1").html(infoDiv);
			}
		}
	});
	//星级会员
	$.post(url,{'locChannelId':50,'locThemeId':52},function(data){
		if(data.success == true){
			if(data.data.infoList.length > 0) {
				var infoDiv = '';
				$.each(data.data.infoList,function(i,v){
					infoDiv += '<a target="_blank" href="'+v.coverPicUrl+'"><img src="'+v.attach +'" height="85px"/></a>'
				});
				$("#demo1").html(infoDiv);
				$("#demo2").html(infoDiv);
			}
		}
	});
	//东盟航线船期
	var cqurl= mainDomain + '/front/showtshx';
	$.post(cqurl,{'hxid':2,'rows':8,'sort':'lgsj'},function(data){
		if(data.success == true){
			if(data.data.infoList.length > 0) {
				var infoDiv = '<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF" id="hxtable3" >';
					infoDiv += '<tbody><tr style="background-color: rgb(217, 235, 255);">';
					infoDiv += '<td bgcolor="#C3DEF9" height="35" align="center"><strong>船名</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>航线经营人</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>航次</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>始发港</strong></td>'; 
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>到达港</strong></td>'; 
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>离港时间</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>抵港时间</strong></td>';
					infoDiv += '</tr>';
				$.each(data.data.infoList,function(i,v){
					if(i%2==0){
						infoDiv += '<tr style="background-color: rgb(228, 242, 255);">';
					}
					else{
						infoDiv += '<tr style="background-color: rgb(217, 235, 255);">';
					}
					infoDiv += '<td height="35" align="center">'+v.cbmc+'</td>';
					infoDiv += '<td height="35" align="center">'+v.hxjyz+'</td>';
					infoDiv += '<td height="35" align="center">'+v.hc+'</td>';
					infoDiv += '<td height="35" align="center">'+v.sfGkinfoVO.gkmc+'</td>';
					infoDiv += '<td height="35" align="center">'+v.mdGkinfoVO.gkmc+'</td>';
					infoDiv += '<td height="35" align="center">'+dateToStr(v.lgsj)+'</td>';
					infoDiv += '<td height="35" align="center">'+dateToStr(v.dgsj)+'</td></tr>';
				});
				infoDiv += '</tbody></table>'
				console.log(infoDiv);
				$("#cont_hx_1").html(infoDiv);
			}
		}
	});
	
	//江海直达船期
	$.post(cqurl,{'hxid':1,'rows':8,'sort':'lgsj'},function(data){
		if(data.success == true){
			if(data.data.infoList.length > 0) {
				var infoDiv = '<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#FFFFFF" id="hxtable3" >';
					infoDiv += '<tbody><tr style="background-color: rgb(217, 235, 255);">';
					infoDiv += '<td bgcolor="#C3DEF9" height="35" align="center"><strong>船名</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>航线经营人</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>航次</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>始发港</strong></td>'; 
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>到达港</strong></td>'; 
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>离港时间</strong></td>';
					infoDiv += '<td bgcolor="#C3DEF9" align="center"><strong>靠港时间</strong></td>';
					infoDiv += '</tr>';
				$.each(data.data.infoList,function(i,v){
					if(i%2==0){
						infoDiv += '<tr style="background-color: rgb(228, 242, 255);">';
					}
					else{
						infoDiv += '<tr style="background-color: rgb(217, 235, 255);">';
					}
					infoDiv += '<td height="35" align="center">'+v.cbmc+'</td>';
					infoDiv += '<td height="35" align="center">'+v.hxjyz+'</td>';
					infoDiv += '<td height="35" align="center">'+v.hc+'</td>';
					infoDiv += '<td height="35" align="center">'+v.sfGkinfoVO.gkmc+'</td>';
					infoDiv += '<td height="35" align="center">'+v.mdGkinfoVO.gkmc+'</td>';
					infoDiv += '<td height="35" align="center">'+dateToStr(v.lgsj)+'</td>';
					infoDiv += '<td height="35" align="center">'+dateToStr(v.dgsj)+'</td></tr>';
				});
				infoDiv += '</tbody></table>'
				console.log(infoDiv);
				$("#cont_hx_2").html(infoDiv);
			}
		}
	});
}

function changetitle(locThemeId,newid){
	
	var url= mainDomain + '/front/findArticleList.action';
	$.post(url,{'id':newid},function(data){
		if(data.success == false){
			console.log(data.message);
		}else{
			if(data.data.infoList.length > 0) {
				document.getElementById("hid" + locThemeId).innerHTML = data.data.infoList[0].title;
				document.getElementById("pid" + locThemeId).innerHTML = data.data.infoList[0].infoNote;
			}
		}
	});
}

function  dateToStrTshx(dateTime){
	if(dateTime==null){
		return "";
	}
	var date = new Date(dateTime);
	Y=date.getFullYear(); 
	M=(date.getMonth()+1)<10?("0"+(date.getMonth()+1)) : (date.getMonth()+1);
	D=date.getDate()<10?("0"+date.getDate()) : date.getDate();
	var hh = "";
	var mm = "";
	if(date.getHours()>0||date.getMinutes()>0){
		hh = date.getHours()<10?("0"+date.getHours()) : date.getHours();
		mm = date.getMinutes()<10?("0"+date.getMinutes()) : date.getMinutes();
		return Y+'-'+M+'-'+D+' '+hh+':'+mm;
	}
	else{
		return Y+'-'+M+'-'+D; 
	}	
}

function  dateToStr(dateTime){
	if(dateTime==null){
		return "";
	}
	var date = new Date(dateTime);
	Y=date.getFullYear(); 
	M=(date.getMonth()+1)<10?("0"+(date.getMonth()+1)) : (date.getMonth()+1);
	D=date.getDate()<10?("0"+date.getDate()) : date.getDate();
	var hh = date.getHours()<10?("0"+date.getHours()) : date.getHours();
	var mm = date.getMinutes()<10?("0"+date.getMinutes()) : date.getMinutes();
	return Y+'-'+M+'-'+D; 
}
//---------------------------------------------------------------------------
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
